﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for RoleAdapter
/// </summary>
public class RoleAdapter
{
	public RoleAdapter()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    /// <summary>
    /// get list role
    /// </summary>    
    /// <returns></returns>
    public List<Role> getAllRoles()
    {
        BookContextDataContext context = new BookContextDataContext();
        try
        {
            List<Role> lstRoles = (from r in context.Roles
                           select r).ToList();         
            return lstRoles;
        }
        catch { return null; }
    }
    /// <summary>
    /// get list role
    /// </summary>    
    /// <returns></returns>
    public Role getRoleById(long roleId)
    {
        BookContextDataContext context = new BookContextDataContext();
        try
        {
            var lstRoles = from u in context.Roles
                           where u.ID == roleId
                           select u;

            return (Role)lstRoles.First();
        }
        catch { return null; }
    }
}
